package com.hong.activiti;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task;

import java.util.List;

/**
 * @Auther: csh
 * @Date: 2019/11/19 19:41
 * @Description:查询当前用户的任务列表
 */
public class ActivitiCompleteTask {
    //查询当前用户的任务并处理掉
    public static void main(String[] args) {
        //1.得到ProcessEngine对象
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        //2.得到taskService
        TaskService taskService = processEngine.getTaskService();
        //3.查询当前用户的任务
        Task task = taskService.createTaskQuery()
                .processDefinitionKey("holiday2")
                .taskAssignee("王五")
                .singleResult();

        //4.处理任务，结合当前用户列表的查询操作的话，任务ID5002
        taskService.complete(task.getId());

        //5.输出任务的id
        System.out.println(task.getId());
    }
}
